home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
pyxmpp
/
sasl
/
plain.pyo
(
.txt
)
< prev
Wrap
Python Compiled Bytecode
|
2008-10-13
|
3KB
|
93 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
__revision__ = '$Id: plain.py 647 2006-08-26 18:27:39Z jajcus $'
__docformat__ = 'restructuredtext en'
import logging
from pyxmpp.utils import to_utf8, from_utf8
from pyxmpp.sasl.core import ClientAuthenticator, ServerAuthenticator
from pyxmpp.sasl.core import Success, Failure, Challenge, Response
class PlainClientAuthenticator(ClientAuthenticator):
def __init__(self, password_manager):
ClientAuthenticator.__init__(self, password_manager)
self.username = None
self.finished = None
self.password = None
self.authzid = None
self._PlainClientAuthenticator__logger = logging.getLogger('pyxmpp.sasl.PlainClientAuthenticator')
def start(self, username, authzid):
self.username = username
if authzid:
self.authzid = authzid
else:
self.authzid = ''
self.finished = 0
return self.challenge('')
def challenge(self, challenge):
_unused = challenge
if self.finished:
self._PlainClientAuthenticator__logger.debug('Already authenticated')
return Failure('extra-challenge')
self.finished = 1
if self.password is None:
(self.password, pformat) = self.password_manager.get_password(self.username)
if not (self.password) or pformat != 'plain':
self._PlainClientAuthenticator__logger.debug("Couldn't retrieve plain password")
return Failure('password-unavailable')
return Response('%s\x00%s\x00%s' % (to_utf8(self.authzid), to_utf8(self.username), to_utf8(self.password)))
def finish(self, data):
_unused = data
return Success(self.username, None, self.authzid)
class PlainServerAuthenticator(ServerAuthenticator):
def __init__(self, password_manager):
ServerAuthenticator.__init__(self, password_manager)
self._PlainServerAuthenticator__logger = logging.getLogger('pyxmpp.sasl.PlainServerAuthenticator')
def start(self, response):
if not response:
return Challenge('')
return self.response(response)
def response(self, response):
s = response.split('\x00')
if len(s) != 3:
self._PlainServerAuthenticator__logger.debug('Bad response: %r' % (response,))
return Failure('not-authorized')
(authzid, username, password) = s
authzid = from_utf8(authzid)
username = from_utf8(username)
password = from_utf8(password)
if not self.password_manager.check_password(username, password):
self._PlainServerAuthenticator__logger.debug('Bad password. Response was: %r' % (response,))
return Failure('not-authorized')
info = {
'mechanism': 'PLAIN',
'username': username }
if self.password_manager.check_authzid(authzid, info):
return Success(username, None, authzid)
else:
self._PlainServerAuthenticator__logger.debug('Authzid verification failed.')
return Failure('invalid-authzid')